import { ComWindow } from '@shared/classes/ComWindowClass'
import { Subject, BehaviorSubject } from 'rxjs'
import { TemplateRef } from '@angular/core'

export class Country {
  _id?: string
  capital?: string
  cities?: null | []
  codeAlpha2?: string
  codeAlpha3: string
  codeNumeric?: string
  continent?: string
  currencies?: null
  fullName?: string
  languages?: null | []
  name: string
  nameCN?: string
  shortName?: string
}

export interface ICountryQueryParams {
  size: number
  page: number
  keyword?: string
}

// 币种信息
export class Currency {
  _id?: string
  code: string
  decimal: number
  name: string
  number: string
  sign: string
  country?: string
  countryCodeAlpha2?: string
  countryCodeAlpha3?: string
}

export interface ICurrencyQueryParams {
  limit: number
  keyword?: string
}

export interface IDetailHeaderTab {
  text: string
  url: string
  key?: string // 用来定位某个 tab
}

export interface INewPageColumn {
  component: ComWindow
}

export interface INewSelectOption {
  localName: string
  label: string
  value: string
}

export interface IExchangeRateQueryParams {
  dstCurrency: string
  srcCurrency: string
}

/* 表单项 */
export enum FormItemType {
  SELECT = 'select',
  CURRENCY_SELECT = 'currency_select',
  SWITCH = 'switch',
  FILE = 'file',
  TEMPLATE = 'template',
  INPUTGROUP = 'inputGroup',
  RADIO = 'radio',
  INPUTNUMBER = 'inputNumber',
}

export interface IFormItem {
  label: string
  errTip?: string
  errTips?: { [key: string]: string }
  formControlName: string
  inputType?: string
  type?: FormItemType // 输入类型，
  multiple?: 'multiple' | 'tags' | 'default' // 当输入类型是 select 时，可以指定是否多个
  allowClear?: boolean // 当输入类型时 select 时，是否允许删除
  options?: IOption[] // 当输入类型是 select 时，需要提供 对应的 options
  hide?: boolean // 是否隐藏
  asyncHidden?: BehaviorSubject<boolean> // 异步控制是否隐藏
  disable?: boolean // 是否不可编辑
  addAfter?: string // inputGroup 后缀
  noColon?: boolean // 是否不显示 label 后面的冒号，默认false
  asyncSpan?: BehaviorSubject<string> // async nzSpan value
  compareFn?: (c1, c2) => boolean // select 比较方法
  change?: (event: any) => void // 用于监听选择项变化时的操作方法
  template?: TemplateRef<void>
  currencyType?: 'string' | 'object'
}

export interface IFormOption {
  label: string
  errTip: string
  formControlName: string
  type?: FormItemType
  multiple?: boolean
  options?: any[]
}

export interface IOption {
  label: string
  value: string | number
}

export interface ICurrencyOption {
  label: string
  value: Currency
}
export interface IChannelOption {
  label: string
  value: string
}
/* 渠道信息 */
export enum ChanCodeValue {
  WXP = 'WXP',
  ALP = 'ALP',
  UPI = 'UPI',
  VIS = 'VIS',
  MCC = 'MCC',
  JCB = 'JCB',
  TRU = 'TRU'
  // GRB = 'GRB',
  // WHK = 'WHK',
  // TRU = 'TRU',
  // DOT = 'DOT',
  // TIS = 'TIS',
  // CIL = 'CIL',
  // FPS = 'FPS',
}

export enum ChanCodeLabel {
  ALP = 'Alipay',
  WXP = 'WeChat',
  UPI = 'UPI',
  VIS = 'Visa',
  MCC = 'MasterCard',
  JCB = 'JCB',
  TRU = 'TRU'
  // GRB = 'GRB',
  // WHK = 'WeChat HK',
  // TRU = 'TrueMoney',
  // DOT = 'DOT',
  // TIS = 'TIS',
  // CIL = 'CIL',

  // FPS = 'FPS',
}

export enum CardChanCodeLabel {
  VIS = 'Visa',
  MCC = 'MasterCard',
  AME = 'American Express',
  UPI = 'UPI',
}

export enum CardChanCodeValue {
  VIS = 'VIS',
  MCC = 'MCC',
  AME = 'AME',
  UPI = 'UPI',
}

// 汇率，公共接口
export interface IExchangeRate {
  buyRate: number
  createTime: string
  dstCurrency: string
  id: string
  isCalculate: boolean
  isNew: boolean
  markup: number
  rateSponsor: string
  relateRates: string[]
  selRate: number
  srcCurrency: string
  updateTime: string
}

// 日期选择
export enum EDateLimitEnum {
  Year = 'year',
  Month = 'month',
}

// 业务层级
export const BizAreaOptions = [
  {
    label: 'CIL',
    value: 'CIL',
  },
  {
    label: 'THA',
    value: 'THA',
  },
  {
    label: 'TIS',
    value: 'TIS',
  },
  {
    label: 'MZH',
    value: 'MZH',
  },
  {
    label: 'IDA',
    value: 'IDA',
  },
  {
    label: 'TYO',
    value: 'TYO',
  },
  {
    label: 'SGP',
    value: 'SGP',
  },
  {
    label: 'GRB',
    value: 'GRB',
  },
]
// 状态
export const StatusTextMap = {
  init: 'GENERAL.STATUS.INIT',
  normal: 'GENERAL.STATUS.NORMAL',
  freeze: 'GENERAL.STATUS.FREEZE',
}
// 终端的状态(特殊翻译)
export const StatusTextMapForTerminal = {
  init: 'GENERAL.STATUS.INIT',
  normal: 'GENERAL.STATUS.NORMAL.TERMINAL',
  freeze: 'GENERAL.STATUS.FREEZE',
}
// 风控方案的状态
export const SchemeStatusTextMap = {
  '': '-',
  0: 'GENERAL.STATUS.NORMAL',
  1: 'GENERAL.STATUS.FREEZE',
}
// 风控方案规则属性
export const RuleTypeTextMap = {
  1: 'GENERAL.RULE_TYPE_AUTH',
  2: 'GENERAL.RULE_TYPE_SETTLEMENT',
}
// 风控类型
export const RiskTypeMap = {
  normal: 'RISK_CTRL_CATEGORY.NORMAL',
  special: 'RISK_CTRL_CATEGORY.SPECIAL',
}
// 用户类型
export const UserTypeTextMap = {
  admin: 'USERTYPE.ADMIN',
  genAdmin: 'USERTYPE.GENADMIN',
  institution: 'USERTYPE.INSTITUTION',
  agent: 'USERTYPE.AGENT',
  merchant: 'USERTYPE.MERCHANT',
  store: 'USERTYPE.STORE',
}

// 层级映射
export const LevelMap = {
  institution: '机构',
  agent: '集团',
  merchant: '商户',
  store: '门店',
}

/** 后端成功信息 */
export enum SuccessCode {
  SUCCESS_AUDITING = 'MSG_CODE.SYSTEM.SUCCESS_AUDITING',
  SUCCESS = 'MSG_CODE.SYSTEM.SUCCESS',
}

/** 后端报错信息 */
export enum ErrorCode {
  ALREADY_IN_AUDIT = 'MSG_CODE.PERMISSION.ALREADY_IN_AUDIT',
}

export enum EcPaymentBrandLabel {
  UPI = 'UPI',
  KBANK= 'KBANK'
}

export enum EcPaymentBrandValue {
  UPI = 'UPI',
  KBANK= 'KBank'
}

export enum channelCode {
  KBank = 'KBank',
}

// 批导状态
export const  BatchStatusTextMap = {
  '': '-',
  0: 'TRADE_STATUS.REJECT',
  1: 'TRANS_PROC.RESOLVE',
  2: 'TRANS_PROC.RESOLVE',
}

export enum ECurrencyDecimal {
  ZERO = 0,
  TWO = 2
}

/** 交易的清算状态 */
export const  TradeSettStatusMap = {
  '': '-',
  0: false,
  1: true,
}

/** 交易的清算状态 */
export const  TradeSettStatusTextMap = {
  '': '-',
  false: 'TRADE.SETTLE.UNSETTLED',
  true: 'TRADE.SETTLE.SETTLED',
}
